package com.example.dicos.controller;

import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import com.example.dicos.entity.WxUser;


public abstract class BaseController {

    /**
     * 获取当前登录用户 ID
     * @return
     */
    protected Long getUserById() {
        SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
        tokenInfo.getLoginId();
        WxUser user = StpUtil.getSession().getModel("user", WxUser.class);
        System.out.println(user.getUserName());
        return user.getId();
    }


    protected String getUserName() {
        SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
        tokenInfo.getLoginId();
        WxUser user = StpUtil.getSession().getModel("user", WxUser.class);
        System.out.println(user.getUserName());
        return user.getUserName();
    }

}
